package cn.xsshome.algorithmNation.sample;


import cn.xsshome.algorithmNation.model.AntCipherRO;

/**
 * SM2加解密
 *
 * @author 小帅丶
 */
public class Test {

    public static final int CLIENT_ID = 1;

    public static final byte[] CONTENT = "{\"username\":\"何顺\"}".getBytes();
    //    public static final BigInteger clinetId = new BigInteger(CLIENT_ID, CENTNET_PRIVATE_KEY);
    public static final String clientId = "beijin_xingzhenzongdui";

    public static void main(String[] args) throws Exception {


//        String encoded = post();
//        System.out.println(encoded);
    }

    public static <T> T getData(AntCipherRO ro, Class<T> clazz) {
//        SM2VerifySign.VerifySignSM2(ALI_PUBLICK_KEY, ro.getSign().getBytes(), ro.getClientId());


        return null;
    }
//
//    private static String post() throws Exception {
//        byte[] sm4Key = createSm4PrivateKey();
//        byte[] sm4Ciphertext = createSm4Ciphertext(sm4Key, CONTENT);
//        String sm4CipherKey = cipherSm4Key(ALI_PUBLICK_KEY, sm4Key);
//        SM2SignVO data = signData(CENTNET_PRIVATE_KEY, sm4Ciphertext);
//        SM2SignVO keyData = signSm4Key(CENTNET_PRIVATE_KEY, sm4CipherKey.getBytes());
//        AntCipherRO ro = new AntCipherRO(clinetId, 1, data.sm2_sign, keyData.sm2_sign);
//        return postHighRiskTrade(ro);
//    }
//
//    private static SM2SignVO signSm4Key(byte[] privateKey, byte[] key) throws Exception {
//        return SM2VerifySign.Sign2SM2(key, clinetId);
//    }
//
//    private static String postHighRiskTrade(AntCipherRO ro) {
//        String body = HttpRequest.post("https://oafsc.alipay.com/gateway/v1/service.json").body(JSONUtil.toJsonStr(ro)).execute().body();
//        return body;
//
//    }
//
//    private static SM2SignVO signData(byte[] privateKey, byte[] sm4Ciphertext) throws Exception {
//        return SM2VerifySign.Sign2SM2(sm4Ciphertext, clinetId);
//    }
//
//    private static String cipherSm4Key(byte[] publicKey, byte[] sm4Key) {
//        return SM2EnDecryption.encrypt(publicKey, sm4Key);
//    }
//
//    private static byte[] createSm4Ciphertext(byte[] sm4PrivateKey, byte[] content) throws NoSuchPaddingException, NoSuchAlgorithmException, IllegalBlockSizeException, BadPaddingException, NoSuchProviderException, InvalidKeyException {
//        return SM4EnDecryption.encrypt_Ecb_Padding(sm4PrivateKey, content);
//    }
//
//
//    private static byte[] createSm4PrivateKey() throws NoSuchProviderException, NoSuchAlgorithmException {
//        return SM4EnDecryption.generateKey();
//    }
//
//    private static void testSm2() throws IOException {
//        String text = "测试111111wqsdfsdfsdfsadasdasdsa";
//        byte[] source = text.getBytes();
//        String publicKey = "BKC6kiLpAdou7J53TEmVG9/gqSShagUFFZTQC7DEdVA3ej2clZuBXfUT5SjUZgkII3CyeeuI6moghxHi3mCjqVU=";
//        byte[] decode = Base64.decode(publicKey);
//        String result = SM2EnDecryption.encrypt(decode, source);
//        System.out.println(result);
////		String privatekey = "5EB4DF17021CC719B678D970C620690A11B29C8357D71FA4FF9BF7FB6D89767A";
//        byte[] privatekey = Base64.decode("CNRNGnTaYCE3s8pTaPMKvgeiSF7Nw8JOBxQTpMUrrIY=");
//        byte[] decryptresult = SM2EnDecryption.decrypt(privatekey, Util.hexToByte(result));
//        System.out.println(new String(decryptresult));
//    }


}
